package datasv.courseProduce_datasv;

import data.datafactory.DatabaseOperator;
import po.CourseAssistPO;

public class GetCourseAssist {
	public static void main(String[] args) {
		System.out.println(new GetCourseAssist().getCourseAssist("00106130020").getReferenceBook());
	}
	public CourseAssistPO getCourseAssist(String courseID){
		return getInSql(courseID);
	}
	private CourseAssistPO getInSql(String courseID){
		String collegeID=courseID.substring(0,3);
		DatabaseOperator op=new DatabaseOperator("college"+collegeID);
		if(!op.ifDatabaseExist()||!op.ifIDExist("course_list", courseID)){
			return null;
		}
		int columnNum=AddCourseAssist.columnNum;
		String[] columnName=AddCourseAssist.columnName;
		String[] result=new String[columnNum];
		for (int i = 0; i < columnName.length; i++) {
			String m=op.getOneInform(courseID, "course_list", columnName[i]);
			try{
				m.equals(null);
				System.out.println(columnName[i]+" is "+m);
			}catch(NullPointerException e){
				System.out.println(columnName[i]+" is "+m);
			}
			System.out.println(columnName[i]+" : "+m);
			result[i]=m;
		}
		return new CourseAssistPO(courseID, result[1], result[2], result[3]);
	}
}
